package net.zjitc.service.impl;

import net.zjitc.common.ServiceResponse;
import net.zjitc.mapper.NoticeMapper;
import net.zjitc.pojo.Notice;
import net.zjitc.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author admin
 * @Date 2019/4/1 9:07
 */
@Service
@Transactional
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    NoticeMapper noticeMapper;

    @Override
    public List<Notice> findAll() {
        return noticeMapper.findAll();
    }

    @Override
    public Notice findById(int id) {
        return noticeMapper.findById(id);
    }

    @Override
    public ServiceResponse updateById(Notice notice) {
        int reultCount = noticeMapper.updateById(notice);
        if (reultCount>0){
            return ServiceResponse.createBySuccessAndMessage("修改成功");
        }
        return ServiceResponse.createByErrorMessage("修改失败");

    }

    @Override
    public int addNotice(Notice notice) {
        return noticeMapper.addNotice(notice);
    }

    @Override
    public int deleteNotice(int id) {
        return noticeMapper.deleteNotice(id);
    }

    @Override
    public Notice descNoticeDate() {
        return noticeMapper.descNoticeDate();
    }
}
